package com.atguigu.gulimall.cart.vo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 购物车
 */

public class CartVo {
    private List<CartItemVo> vos;
    private Integer countNum;//商品数量
    private Integer coutTyoe;//商品类型数量
    private BigDecimal coutPrice;//商品总价
    private BigDecimal reduce = new BigDecimal("0");//商品减免价格

    public List<CartItemVo> getVos() {
        return vos;
    }

    public void setVos(List<CartItemVo> vos) {
        this.vos = vos;
    }

    /**
     * 计算商品总数量
     * @return
     */
    public Integer getCountNum() {
        int num = 0;
        List<CartItemVo> vos = this.vos;
        if (vos!=null&&vos.size()>0){
            for (CartItemVo vo : vos) {
                num=vo.getCount()+num;
            }
        }
        return num;
    }

    /**
     * 获取商品类型数量
     * @return
     */
    public Integer getCoutTyoe() {
        int num = 0;
        List<CartItemVo> vos = this.vos;
        for (CartItemVo vo : vos) {
            num++;
        }
        return num;
    }

    /**
     * 计算商品总价
     * @return
     */
    public BigDecimal getCoutPrice() {
        BigDecimal bigDecimal = new BigDecimal("0");
        List<CartItemVo> vos = this.vos;
        for (CartItemVo vo : vos) {
            //如果商品被选中的话
            if (vo.getCheck()){
            BigDecimal price = vo.getTotalPrice();
            bigDecimal = bigDecimal.add(price);
           }
        }
        return bigDecimal;
    }

    public void setCoutPrice(BigDecimal coutPrice) {
        this.coutPrice = coutPrice;
    }

    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
